﻿using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.InterceptionExtension;
using TSharp.Core.Authentication.Facade;

namespace TSharp.Core.Authentication.Impl
{
    /// <summary>
    /// 服务注册
    /// <para>2010/8/4</para>
    /// 	<para>TANGJINGBO</para>
    /// 	<para>tangjingbo</para>
    /// </summary>
    public class AuthenticationInterception : Interception
    {
        /// <summary>
        /// Initial the container with this extension'detectorObj functionality.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            Registered(Container);
        }


        /// <summary>
        /// Removes the extension'detectorObj functions from the container.
        /// </summary>
        /// <remarks>
        /// 	<para>
        /// This method is called when extensions are being removed from the container. It can be
        /// used to do things like disconnect event handlers or clean up member state. You do not
        /// need to remove strategies or policies here; the container will do that automatically.
        /// </para>
        /// 	<para>
        /// The default implementation of this method does nothing.</para>
        /// </remarks>
        public override void Remove()
        {
            base.Remove();
            Remove(Container);
        }

        private void Registered(IUnityContainer container)
        {
            container.RegisterType<IMembershipService, MembershipService>();
            container.RegisterType<IAuthenticationService, AuthenticationService>();
            container.RegisterType<ITokenService, TokenService>();
            container.RegisterType<IUserExtendService, UserExtendService>();
            container.RegisterType<IMailService, MailService>();
        }

        private void Remove(IUnityContainer container)
        {
        }
    }
}